local skill = fk.CreateSkill{
  name = "hanqing__taigong_tactics_skill&",
  attached_equip = "hanqing__taigong_tactics",
}

Fk:loadTranslationTable{
  ["hanqing__taigong_tactics_skill&"] = "太公兵法",
  [":hanqing__taigong_tactics_skill&"] = "若你没有手牌，你可以摸一张牌，视为使用你上次使用的普通锦囊牌。",

  ["#hanqing__taigong_tactics_skill"] = "太公兵法：摸一张牌，视为使用【%arg】",
}

skill:addEffect("viewas", {
  pattern = ".|.|.|.|.|trick",
  prompt = function (self, player, selected_cards, selected)
    return "#hanqing__taigong_tactics_skill:::"..player:getMark("hanqing__taigong_tactics")
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    if player:getMark("hanqing__taigong_tactics") == 0 then return end
    local card = Fk:cloneCard(player:getMark("hanqing__taigong_tactics"))
    card.skillName = skill.name
    return card
  end,
  before_use = function(self, player, use)
    player:drawCards(1, skill.name)
  end,
  enabled_at_play = function(self, player)
    return player:isKongcheng() and player:getMark("hanqing__taigong_tactics") ~= 0
  end,
  enabled_at_response = function(self, player, response)
    return not response and player:isKongcheng() and player:getMark("hanqing__taigong_tactics") ~= 0
  end,
  enabled_at_nullification = function (self, player, data)
    return player:isKongcheng() and player:getMark("hanqing__taigong_tactics") == "nullification"
  end,
})

skill:addEffect(fk.AfterCardUseDeclared, {
  can_refresh = function (self, event, target, player, data)
    return target == player and player:hasSkill(skill.name, true) and data.card:isCommonTrick()
  end,
  on_refresh = function (self, event, target, player, data)
    player.room:setPlayerMark(player, "hanqing__taigong_tactics", data.card.name)
  end,
})

skill:addAI(nil, "vs_skill")

return skill
